from django.db import models
from django import forms
from django.forms import ModelForm
from django.contrib.auth.models import User
from betting.board.models import BetModel
# Create your models here.

class LoginForm(forms.Form):
    username = forms.CharField(max_length=100,widget=forms.TextInput(attrs={'place':'Enter Username','require':'True','label':'Username'}))
    password = forms.CharField(widget=forms.PasswordInput(render_value=False,attrs={'place':'Enter Password','require':'True','label':'Password'}),max_length=100)

class BankModel(models.Model):
    user = models.ForeignKey(User, unique=True)
    bankroll =models.IntegerField()
    total_bets = models.IntegerField()
    current_bets = models.IntegerField()

class UserBetsModel(models.Model):
    user = models.ForeignKey(User)
    bet = models.ForeignKey(BetModel)
    double_down = models.BooleanField()
    buy = models.BooleanField()
    price = models.IntegerField()
    bet_return = models.IntegerField()
    return_sign = models.BooleanField()
    expired = models.DateTimeField()
    premature = models.BooleanField()
    pre_buy = models.BooleanField()
    pre_price = models.IntegerField()
    
class UserProfile(models.Model):
    user = models.ForeignKey(User, unique=True)
    username = models.CharField(max_length=100)
    email = models.CharField(max_length=100)
    password = models.CharField(max_length=100)
    
    GENDER_CHOICES = (              
        ('M', 'Male'),
        ('F', 'Female'),
    )
    
    AGE_CHOICES = (
        ('18-30', '18-30'),
        ('30-50', '30-50'),
        ('50-75', '50-75'),
        ('75+', '75+'),
    )
    gender = models.CharField(max_length=1,choices=GENDER_CHOICES,blank=False,default='M')
    age = models.CharField(max_length=100,choices=AGE_CHOICES,blank=False,default='18-30')
    zip = models.IntegerField(max_length=5)
    
class DailyBet(models.Model):
    bet = models.ForeignKey(BetModel)
    

class CommentForm(forms.Form):
    anon = forms.BooleanField(required=False)
    comment = forms.CharField(widget=forms.Textarea(attrs={'rows':'15', 'cols':'60'}))
    
class RegisterForm(ModelForm):
    passwordagain =  forms.CharField(max_length=100,widget=forms.PasswordInput(render_value=False,attrs={'place':'Re-type password','match':'password','label':'Password'}))
    class Meta:
        model = UserProfile 
        exclude = ('user') 
        widgets= {'password': forms.PasswordInput(render_value=False,attrs={'place':'Password','require':'True','label':'Password'}),
                  'username':forms.TextInput(attrs={'place':'Choose a username','require':'True','label':'Username'}),
                  'email':forms.TextInput(attrs={'place':'Email address','validate':'email','label':'Email'}),
                  'zip':forms.TextInput(attrs={'place':'Zip code','label':'Zip code','require':'True'})}

class ChangePass(forms.Form):
    password =  forms.CharField(max_length=100,widget=forms.PasswordInput(render_value=False,attrs={'place':'Enter password','label':'Password'}))
    passwordagain =  forms.CharField(max_length=100,widget=forms.PasswordInput(render_value=False,attrs={'place':'Re-type password','match':'password','label':'Password'}))

class ChangeEmail(forms.Form):
    email = forms.CharField(max_length=100,widget=forms.TextInput(attrs={'place':'Email address','validate':'email','label':'Email'}))